package gspushmq.v1.app.subscribeapp.enumeration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @Description 消费者枚举
 * @Author chengsj
 * @Version 1.0
 *
 */
public enum ConsumerEnum {

    Android(6701,"安卓端消费","ANDROID"),
    iOS(6702,"iOS端消费","iOS");
//    PC(6708,"PC端消费","终端");

    int code ;
    String name;
    String channel;

    ConsumerEnum(int code, String name, String channel) {
        this.code = code;
        this.name = name;
        this.channel = channel;
    }

    public static String getNameByCode(Integer code){
        if (code == null)
            return null;
        for (ConsumerEnum en : ConsumerEnum.values())
            if (en.getCode() == code)
                return en.getName();
        return null;
    }
    public static boolean contain(Integer code){
        if (code == null)
            return false;
        for (ConsumerEnum en : ConsumerEnum.values())
            if (en.getCode() == code)
                return true;
        return false;
    }

    public static List<Map<String, Object>> fromChannelKeyToValue(){
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        for(ConsumerEnum type : ConsumerEnum.values()) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("channel", type.getCode());
            map.put("channel_name", type.getChannel());
            list.add(map);
        }
        return list;
    }

    public int getCode() {
        return code;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
